<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <!-- 
      默认情况下组件之间的数据是不共享的
      每个组件都只能使用自己的数据
     -->

    <!-- 
      1. 在父组件的子组件标签上面添加自定义属性(传递)
      2. 在子组件里面使用props选项进行接收
      -->
    <div id="app">
      <h2>组件传参 - 父传子 - {{ count }}</h2>
      <child msg="hello" :count="count"></child>
    </div>

    <script src="./lib/vue3.js"></script>
    <script>
      const { createApp } = Vue;

      const Child = {
        props: ["msg", "count"],
        template: `
          <div>这是child子组件 - {{ msg }} - {{ count }}</div>
        `,
      };

      const app = createApp({
        data() {
          return {
            count: 10,
          };
        },
        components: {
          Child,
        },
      });

      app.mount("#app");
    </script>
  </body>
</html>
